<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>寄生方式</title>
</head>
<body>
<script>
  function beget(obj) {
    var F = function () {

    };
    F.prototype = obj;
    return new F();
  }

  function Super() {
    this.val = 1;
    this.arr = [1];
  }

  function getSubObject(obj) {
    var clone = beget(obj);
    clone.attr1 = 1;
    clone.attr2 = 2;
    return clone;
  }

  var sub = getSubObject(new Super());
  console.log(sub);
  console.log(sub.val);
  console.log(sub.arr);
  console.log(sub.attr1);
</script>
</body>
</html>